package com.caigou.modules.forum.ui.comment

import androidx.activity.viewModels
import com.alibaba.android.arouter.facade.annotation.Route
import com.caigou.comm.base.bean.AppBackgroundInfo
import com.caigou.comm.base.constants.RouterPath
import com.caigou.comm.base.container.BaseReplyActivity
import com.caigou.comm.base.ext.observe
import com.caigou.modules.forum.viewmodel.NoticeViewModel
import dagger.hilt.android.AndroidEntryPoint
import java.io.File

/**
 * @author #Suyghur.
 * Created on 2021/12/04
 */
@Route(path = RouterPath.Forum.PAGE_NOTICE_COMMENT_REPLY)
@AndroidEntryPoint
class NoticeCommentReplyActivity : BaseReplyActivity() {

    private val noticeViewModel: NoticeViewModel by viewModels()

    override fun initView() {
        super.initView()

        binding.replyBtnSubmit.setOnClickListener {
            val content = binding.replyEtContent.text.toString()
            val files: MutableList<File> = mutableListOf()
            urls.forEach {
                files.add(File(it))
            }
            noticeViewModel.setCommentReply(
                content, files, AppBackgroundInfo.instance.userBean!!.userId,
                itemBean.replyUserInfoVo.userId, itemBean.dataId, rootItemBean.replyId
            )
        }
    }

    override fun observeViewModel() {
        observe(noticeViewModel.commentReplyLiveData, ::handleSetReply)
    }

}